<template>
  <div>
    <van-swipe-cell v-for="(idem,index) in data" :key="index">
      <van-card
        :num="idem.goodsCount"
        :price="idem.sellingPrice"
        :title="idem.goodsName"
        class="goods-card"
        :thumb="idem.goodsCoverImg"
      >
        <template #footer>
            <van-stepper v-model="value" integer @plus="plus(value,index)" />
        </template>
      </van-card>
      <template #right>
        <van-button square text="删除" type="danger" class="delete-button" />
      </template>
    </van-swipe-cell>
  </div>
</template>

<script>
import {getCart} from '@/api/api.js'
export default {
  data () {
    return {
      value: 1,
      data: []
    }
  },
  beforeCreate () {
    getCart({ pageNumber: 1 }).then((res) => {
      console.log(res, '购物车的数据')
      this.data = res.data.data
    })
  },
  methods: {
    plus (value, index) {
      value = this.data[index].goodsCount
    }
  }
}
</script>

<style lang="less" scoped>
.goods-card {
  margin: 0;
  background-color: white;
}

.delete-button {
  height: 100%;
}
</style>
